﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using LightWeightORM.ORM.TableAccessor;
using SmartWarehouse.Common;
using SmartWarehouse.ORM.Entity;
using SmartWarehouse.Config;

namespace SmartWarehouse
{
    namespace BussinessLogic
    {
        namespace Basis
        {
            /// <summary>
            /// Summary description for MovementTypeFacade
            /// </summary>
            public class MovementTypeFacade
            {
                private TableAccessor<SwMovementType> _movementTypeAccessor;

                public TableAccessor<SwMovementType> MovementTypeAccessor
                {
                    get { return _movementTypeAccessor; }
                    set { _movementTypeAccessor = value; }
                }
                public MovementTypeFacade()
                {
                    this.MovementTypeAccessor = AccessorFactory.MovementTypeAccessor;
                }

                public SwMovementType[] GetMovementType(bool isGoodReceive)
                {
                    if (isGoodReceive)
                        return this.MovementTypeAccessor.GetMuch(new Filter(SwMovementType._Inv, "1", ComparisonOperator.Equal));
                    else
                        return this.MovementTypeAccessor.GetMuch(new Filter(SwMovementType._Inv, "-1", ComparisonOperator.Equal));
                }

                public SwMovementType GetMovementTypeByName(string movementName)
                {
                    return this.MovementTypeAccessor.GetOne(new Filter(SwMovementType._Name, movementName, ComparisonOperator.Equal));
                }
            }
        }
    }
}